package ge.unihack.instantdj;

import ge.unihack.instantdj.protocol.common.LayerInfo;
import ge.unihack.instantdj.utils.LayerListAdapter;

import java.util.Random;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;

public class DJActivity extends Activity{

	private LayerListAdapter mAdapter;
	private ListView mListView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_dj);
		
//		Server s = new InstantDJServer();
//		try {
//			//s.start();
////			String add = s.getLocalAddress();
////			Toast.makeText(this, add, Toast.LENGTH_SHORT).show();
//		} catch (IOException e) {
//			throw new RuntimeException(e);
//		}
		
		setupViews();
		Random rand = new Random();
		for(int i=0; i<7; i++){
			LayerInfo li = new LayerInfo();
			li.setName("drum_" + rand.nextInt(7));
			mAdapter.addItem(li);
		}
	}
	
	private void setupViews(){
		mListView = (ListView) findViewById(R.id.lvLayers);
		mAdapter = new LayerListAdapter(this);
		mListView.setAdapter(mAdapter);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.dj_menu, menu);
		return super.onCreateOptionsMenu(menu);
	}
}
